package cn.shuangliang.contract.service;

import cn.shuangliang.contract.dao.ContracthistoryMapper;
import cn.shuangliang.contract.dao.ProductMapper;
import cn.shuangliang.contract.model.Contracthistory;
import cn.shuangliang.contract.model.Product;
import cn.shuangliang.contract.util.MyBatisUtil;
import cn.shuangliang.contract.vo.Constant;
import cn.shuangliang.contract.vo.Page;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
public class HistoryService {

    public Page<Contracthistory> search(  int pageNo , int pageSize,  String billno,  String pname,   Date start, Date end){

        try {
            ContracthistoryMapper mapper = MyBatisUtil.get().getMapper(ContracthistoryMapper.class);
            List<Contracthistory> search = mapper.search(pageNo, pageSize, billno, pname, start, end);
            int total = mapper.searchTotal(billno, pname, start, end);
            return new Page<Contracthistory>(search,pageNo,total, pageSize);
        } finally {
            MyBatisUtil.close();
        }
    }

    public List<Contracthistory> exportsearch(    String billno,  String pname,   Date start, Date end){

        try {
            ContracthistoryMapper mapper = MyBatisUtil.get().getMapper(ContracthistoryMapper.class);
            List<Contracthistory> search = mapper.exportSearch(billno, pname, start, end);

            return search;
        } finally {
            MyBatisUtil.close();
        }
    }
}
